package com.lmz.project.multitudethread.tuling;

/**
 * 视频配套地址https://www.bilibili.com/video/BV1JCBKYpEua?spm_id_from=333.788.player.switch&vd_source=5052f64c62b3fd3dc44e672f630fd8bf&p=2
 */
public class VolatileVisibilityTest {

    private static volatile boolean initFlag = false;

    public static void main(String[] args) throws InterruptedException {
        new Thread(()->{
            System.out.println("waiting data...");
            while (!initFlag){

            }
            System.out.println("==========success");
        }).start();

        Thread.sleep(2000);

        new Thread(()-> prepardData()).start();
    }


    public static void prepardData() {
        System.out.println("1111");
        initFlag = true;
        System.out.println("2222");
    }




}
